﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>09_网格模型旋转</title>
    <script src="../js/three.js"></script>
</head>
<body>
    <script>
        var scene = new THREE.Scene();
        var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
        var renderer = new THREE.WebGLRenderer({
            antialias: true
        });
        renderer.setSize(window.innerWidth, window.innerHeight);
        document.body.appendChild(renderer.domElement);

        var helper = new THREE.GridHelper(1000, 50, 0x0000ff, 0x808080);
        helper.rotation.x = 0.5;
        scene.add(helper);

        var light = new THREE.DirectionalLight(0xffffff);
        light.position.set(10, 10, 10);
        scene.add(light);

        var geometry = new THREE.BoxGeometry(10, 10, 10);
        var material = new THREE.MeshLambertMaterial({ color: 0xffff00 });
        var box = new THREE.Mesh(geometry, material);
        scene.add(box);
        box.position.z = 20;

        camera.position.set(0, 0, 100);
        camera.lookAt(0, 0, 0);

        var render = function () {
            box.rotation.x += 0.01;
            box.rotation.y += 0.01;
            renderer.render(scene, camera);
            requestAnimationFrame(render);
        }
        render();
    </script>
</body>
</html>
